#include <Arduino.h>
#include <Ticker.h>

#define led 4
Ticker timer;
volatile int interrupt_num;
volatile bool led_state = true;

void IRAM_ATTR timer_interrupt(){
    interrupt_num++;
    Serial.print("interrupt succeed");
    Serial.println(interrupt_num);
    digitalWrite(led,led_state);
    led_state = !led_state;
    timer1_write(5000000);
}

void setup() {
    Serial.begin(115200);
    pinMode(led,OUTPUT);
    timer1_attachInterrupt(timer_interrupt);
    timer1_enable(TIM_DIV16,TIM_EDGE,TIM_SINGLE);
    timer1_write(5000000);
}

void loop() {
    
}
